import React from 'react';
import DataSource from './DataSource';

class CommentInput extends React.Component {
    constructor(props) {
        super(props);
        this.state = {comment: ''};

        this.handleClick = this.handleClick.bind(this);
        this.handleChange = this.handleChange.bind(this);
    }

    handleClick() {
        DataSource.insertComment(this.state.comment);
    }

    handleChange(event) {
        this.setState({comment: event.target.value});
    }

    render() {
        return (
            <>
                <input value={this.state.comment} onChange={this.handleChange} />
                <button onClick={this.handleClick}>
                    ADD
                </button>
            </>
        );
    }
}
export default CommentInput;